.selection-popup {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #2196f3, #1976d2);
  color: white;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(33, 150, 243, 0.2);
  padding: 6px 8px;
  cursor: pointer;
  z-index: 999999;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  animation: popupFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.selection-popup:hover {

  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(33, 150, 243, 0.3);
}

.translate-btn {
  background: none;
  border: none;
  color: white;
  padding: 2px 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.translate-btn:hover {
  /* background: rgba(255, 255, 255, 0.3); */
}

.insert-mode-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.insert-mode-btn svg {
  width: 16px;
  height: 16px;
  fill: white;
  transition: transform 0.3s ease;
}

.insert-mode-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.insert-mode-btn[data-mode="inline"] svg {
  transform: rotate(0deg);
}

.insert-mode-btn[data-mode="newline"] svg {
  transform: rotate(90deg);
}

.translated-text-container {
  position: relative;
  display: block;
  margin: 8px 0;
  opacity: 0;
  transform: translateY(-5px);
  animation: translationFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.translated-text-container.inline {
  display: inline;
  position: relative;
  margin: 0 2px;
  vertical-align: middle;
  max-width: fit-content;
}

.translated-text-container.inline .translated-text {
  color: #1d4ed8;
  font-size: inherit;
  line-height: inherit;
  background: rgba(29, 78, 216, 0.05);
  padding: 0 18px 1px 4px;
  margin: 0;
  border: none;
  border-radius: 3px;
  border-bottom: 1.5px solid #1d4ed8;
  box-shadow: none;
  position: relative;
  word-break: normal;
  white-space: nowrap;
  display: inline;
  font-weight: 500;
  vertical-align: middle;
}

.translated-text-container.inline .translation-delete-btn {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 14px;
  height: 14px;
  opacity: 0;
  transition: opacity 0.15s ease;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 5;
}

.translated-text-container.inline:hover .translation-delete-btn {
  opacity: 1;
}

.translated-text-container.inline .translation-delete-btn:hover {
  background: #f8f8f8;
}

.translated-text-container.inline .translation-delete-btn svg {
  width: 8px;
  height: 8px;
  fill: #666;
}

/* 加载状态只需微调文本样式 */
.translated-text-container.inline.loading .translated-text {
  color: #6b7280;
  border-bottom: 1.5px dashed #6b7280;
  background: rgba(107, 114, 128, 0.05);
}

/* 错误状态 */
.translated-text-container.inline.error .translated-text {
  color: #dc2626;
  border-bottom: 1.5px solid #dc2626;
  background: rgba(220, 38, 38, 0.05);
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
  .translated-text-container.inline .translated-text {
    color: #3b82f6;
    border-bottom: 1.5px solid #3b82f6;
    background: rgba(59, 130, 246, 0.1);
  }
  
  .translated-text-container.inline .translation-delete-btn {
    background: #333;
    border-color: #555;
  }
  
  .translated-text-container.inline .translation-delete-btn:hover {
    background: #444;
  }
  
  .translated-text-container.inline .translation-delete-btn svg {
    fill: #bbb;
  }
  
  .translated-text-container.inline.loading .translated-text {
    color: #9ca3af;
    border-bottom: 1.5px dashed #9ca3af;
    background: rgba(156, 163, 175, 0.1);
  }
  
  .translated-text-container.inline.error .translated-text {
    color: #ef4444;
    border-bottom: 1.5px solid #ef4444;
    background: rgba(239, 68, 68, 0.1);
  }
}

.translation-label {
  position: absolute;
  top: 0;
  left: 0;
  background: #1976d2;
  color: white;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px 0 6px 0;
  z-index: 1;
}

.translation-tag {
  position: absolute;
  top: -10px;
  left: 10px;
  background: #2196f3;
  color: white;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(33, 150, 243, 0.2);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.translated-text {
  position: relative;
  display: block;
  padding: 12px 35px 12px 12px;
  color: #1976d2;
  background: rgba(33, 150, 243, 0.15);
  border-radius: 6px;
  border: 1px solid rgba(33, 150, 243, 0.5);
  border-bottom: 2px wavy #2196f3;
  font-size: 0.95em;
  line-height: 1.5;
  box-shadow: 0 3px 10px rgba(33, 150, 243, 0.12);
  margin-top: 10px;  /* 为标签留出空间 */
}

.translation-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border: none;
  background: rgba(33, 150, 243, 0.1);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.translated-text-container:hover .translation-delete-btn {
  opacity: 1;
}

.translation-delete-btn:hover {
  background: rgba(33, 150, 243, 0.2);
  transform: scale(1.1);
}

.translation-delete-btn svg {
  width: 14px;
  height: 14px;
  fill: #1976d2;
}

@keyframes translationFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 对话界面样式 */
.dataflux-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f5f5f5;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 100%;
  animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-message {
  flex-direction: row;
}

.assistant-message {
  flex-direction: row;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e3f2fd;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-message .message-avatar {
  background: #e8f5e9;
}

.message-avatar svg {
  width: 20px;
  height: 20px;
  fill: #1976d2;
}

.user-message .message-avatar svg {
  fill: #43a047;
}

.message-content {
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  line-height: 1.5;
  font-size: 14px;
  max-width: calc(100% - 44px);
  overflow-wrap: break-word;
  overflow-x: auto;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
}

.user-message .message-content {
  background: #e3f2fd;
  color: #1565c0;
}

.assistant-message .message-content {
  background: white;
  color: #333;
}

/* 滚动条样式 */
.dataflux-sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.dataflux-sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.dataflux-sidebar-content::-webkit-scrollbar-thumb {
  background: #bdbdbd;
  border-radius: 3px;
}

.dataflux-sidebar-content::-webkit-scrollbar-thumb:hover {
  background: #9e9e9e;
}

/* 等待动画样式 */
.message-loading {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-loading span {
    width: 8px;
    height: 8px;
    background: #2196f3;
    border-radius: 50%;
    animation: loadingDots 1.4s infinite ease-in-out both;
}

.message-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.message-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingDots {
    0%, 80%, 100% { 
        opacity: 0;
    }
    40% { 
        opacity: 1;
    }
}

/* 淡入淡出动画 */
.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.fade-in {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

/* Markdown 样式 */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin-top: 16px;
    margin-bottom: 8px;
    line-height: 1.25;
    color: #1565c0;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.2em; }

.message-content p {
    margin: 8px 0;
}

.message-content code {
    background: rgba(33, 150, 243, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #1976d2;
}

.message-content pre {
    overflow-x: auto;
    max-width: 100%;
    padding: 12px;
    background: rgba(33, 150, 243, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(33, 150, 243, 0.2);
}

.message-content pre code {
    white-space: pre;
    display: block;
    min-width: max-content;
    padding: 0;
    background: none;
    color: #333;
}

.message-content ul,
.message-content ol {
    padding-left: 24px;
    margin: 8px 0;
}

.message-content li {
    margin: 4px 0;
}

.message-content blockquote {
    border-left: 4px solid #2196f3;
    margin: 12px 0;
    padding: 8px 16px;
    background: rgba(33, 150, 243, 0.05);
    color: #666;
}

.message-content a {
    color: #2196f3;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content img {
    max-width: 100%;
    border-radius: 4px;
    margin: 8px 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.message-content th,
.message-content td {
    border: 1px solid rgba(33, 150, 243, 0.2);
    padding: 8px;
    text-align: left;
}

.message-content th {
    background: rgba(33, 150, 243, 0.05);
    font-weight: 600;
}

.message-content tr:nth-child(even) {
    background: rgba(33, 150, 243, 0.02);
}

.dataflux-sidebar-resize {
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    cursor: ew-resize;
    background: linear-gradient(to bottom, var(--accent-pink), var(--accent-purple));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dataflux-sidebar-resize:hover {
    opacity: 0.5;
}

/* 拖动时的样式 */
.dataflux-sidebar-resize.dragging {
    opacity: 1;
}

/* 确保内容区域可以水平滚动 */
.message-content {
    overflow-x: auto;
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 代码块样式优化 */
.message-content pre {
    overflow-x: auto;
    max-width: 100%;
    padding: 12px;
    background: rgba(33, 150, 243, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(33, 150, 243, 0.2);
}

.message-content pre code {
    white-space: pre;
    display: block;
    min-width: max-content;
    padding: 0;
    background: none;
    color: #333;
}

/* 内联模式下的标签样式调整 */
.translated-text-container.inline .translation-tag {
    top: -8px;
    left: 8px;
    font-size: 10px;
    padding: 1px 6px;
    background: #4CAF50;
    box-shadow: 0 1px 3px rgba(76, 175, 80, 0.2);
}

/* 新增遮罩层样式 */
.resize-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999998;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
}

/* 修改按钮区域定位 */
.dataflux-sidebar-footer {
  position: sticky;
  bottom: 0;
  background: #fff;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  padding: 16px;
  z-index: 2;
}

/* 添加加载动画样式 */
@keyframes loadingDots {
    0%, 80%, 100% { 
        opacity: 0;
    }
    40% { 
        opacity: 1;
    }
}

.translation-loading {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.translation-loading span {
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    display: inline-block;
    animation: loadingDots 1.4s infinite ease-in-out both;
    opacity: 0.7;
}

.translation-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.translation-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingDots {
    0%, 80%, 100% { 
        transform: scale(0);
    }
    40% { 
        transform: scale(1);
    }
}

/* 更新翻译标签样式 */
.translation-tag {
    position: absolute;
    top: -10px;
    left: 10px;
    background: #2196f3;
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.2);
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 按钮禁用状态样式 */
.dataflux-action-btn.disabled,
.dataflux-input:disabled,
.dataflux-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
    transition: all 0.3s ease;
}

.dataflux-action-btn.disabled {
    background: #f0f0f0;
    box-shadow: none;
    pointer-events: none;
}

.dataflux-input:disabled {
    background-color: #f5f5f5;
    border-color: #ddd;
}

.dataflux-input:disabled::placeholder {
    color: #999;
    font-style: italic;
}

.translation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.model-select {
    padding: 4px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background-color: #fff;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 8px;
}

.model-select:hover {
    border-color: #2196f3;
}

.model-select:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.translation-tag {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #666;
    background-color: #f5f5f5;
    padding: 2px 8px;
    border-radius: 4px;
}

/* 对超长的翻译文本处理 */
@media screen and (max-width: 768px) {
  .translated-text-container.inline .translated-text {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
  }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
  .translated-text-container.inline .translated-text {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
  }
}

@media screen and (min-width: 1025px) {
  .translated-text-container.inline .translated-text {
    max-width: 350px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
  }
}

/* 添加工具提示样式 */
.translated-text-container.inline.tooltip-enabled {
  position: relative;
}

.translated-text-container.inline.tooltip-enabled .translated-text[data-tooltip]:hover::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
  z-index: 1001;
}

.translated-text-container.inline.tooltip-enabled .translated-text[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
  min-width: 100px;
  max-width: 300px;
  text-align: center;
  word-wrap: break-word;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  animation: tooltipFadeIn 0.2s ease forwards;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 5px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* 深色模式下的工具提示样式 */
@media (prefers-color-scheme: dark) {
  .translated-text-container.inline.tooltip-enabled .translated-text[data-tooltip]:hover::before {
    border-color: transparent transparent rgba(255, 255, 255, 0.9) transparent;
  }
  
  .translated-text-container.inline.tooltip-enabled .translated-text[data-tooltip]:hover::after {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* 侧边栏模型选择器样式 */
.dataflux-model-select-container {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 2px;
}

.dataflux-model-select-container label {
  font-size: 13px;
  color: #666;
  margin-right: 10px;
}

.sidebar-model-select {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  background-color: #fff;
  font-size: 13px;
  color: #333;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23666' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sidebar-model-select:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.15);
}

.sidebar-model-select:hover {
  border-color: #2196f3;
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .dataflux-model-select-container label {
    color: #aaa;
  }
  
  .sidebar-model-select {
    background-color: #333;
    border-color: #444;
    color: #eee;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23aaa' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  }
  
  .sidebar-model-select:focus {
    border-color: #64b5f6;
    box-shadow: 0 0 0 2px rgba(100, 181, 246, 0.2);
  }
  
  .sidebar-model-select:hover {
    border-color: #64b5f6;
  }
}

/* 模型提示样式 */
.model-notice {
  font-size: 12px;
  color: #888;
  text-align: center;
  padding: 4px 0;
  margin: -6px 0 6px;
  font-style: italic;
}

@media (prefers-color-scheme: dark) {
  .model-notice {
    color: #aaa;
  }
} 